package cn.edu.nwpu.manager.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;

/**
 * @author Hutengzhong
 * @version 1.0.0
 * @title Student 学生表
 * @description TODO
 * @date 2023/9/16 20:03
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Student {
    private Integer studentId;
    private String studentName;
    private String studentNickName;
    private Integer gender;
    private LocalDate birthday;
    private Integer dormitoryId;
    private Integer academyId;
    private String academyName;
    private Integer classId;
    private String className;
    private Integer groupId;
    private String telephone;
    private String email;
    private String wechat;
    private String remark;
    private String imageUrl;   //图显地址
    private String imageUploadPath;  //图存地址
    private Integer isDeleted;
    public Student(HashMap parameters) {
        // parameters={address=C8, dormitoryName=1103}
        if (parameters == null){
            return;
        }else {
            //try {
                if (parameters.containsKey("studentId")){
                    studentId = Integer.parseInt((String) parameters.get("studentId"));
                }
                if (parameters.containsKey("studentName")){
                    studentName = (String) parameters.get("studentName");
                }
                if (parameters.containsKey("studentNickName")){
                    studentNickName = (String) parameters.get("studentNickName");
                }
                if (parameters.containsKey("gender")){
                    gender = Integer.parseInt((String) parameters.get("gender"));
                }
                if (parameters.containsKey("birthday")){
                    birthday = LocalDate.parse((String) parameters.get("birthday"), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                }
                if (parameters.containsKey("dormitoryId")){
                    dormitoryId = Integer.parseInt((String) parameters.get("dormitoryId"));
                }
                if (parameters.containsKey("academyId")){
                    academyId = Integer.parseInt((String) parameters.get("academyId"));
                }
                if (parameters.containsKey("classId")){
                    classId = Integer.parseInt((String) parameters.get("classId"));
                }
                if (parameters.containsKey("groupId")){
                    groupId = Integer.parseInt((String) parameters.get("groupId"));
                }
                if (parameters.containsKey("telephone")){
                    telephone = (String) parameters.get("telephone");
                }
                if (parameters.containsKey("email")){
                    email = (String) parameters.get("email");
                }
                if (parameters.containsKey("wechat")){
                    wechat = (String) parameters.get("wechat");
                }
                if (parameters.containsKey("remark")){
                    remark = (String) parameters.get("remark");
                }
                if (parameters.containsKey("imageUploadPath")) {
                    imageUploadPath = (String) parameters.get("imageUploadPath");
                }
           /* }catch (Exception e){
                System.out.println("前端传递参数转化异常: 参考类型异常");
            }*/
        }
    }
}
